package redora.test.rdo.service.http;

import redora.test.rdo.service.base.JUnitChildServletBase;

/**
* Dispatcher for http/JSON requests between client and server.
* This servlet will deploy all possible actions on your data (for example delete) without any restrictions.
* You may not want that, so either modify the web.xml and add security there ... [TODO: how?] or add more extensive
* security in this class.
*/ 
public class JUnitChildServlet extends JUnitChildServletBase {

//Example of a simple security override
/*
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		try {
			JUnitChildService service = ServiceFactory.jUnitChildService();
			JUnitChildServiceJSON serviceJSON = ServiceFactory.jUnitChildServiceJSON();
			if (req.getParameter("action").equalsIgnoreCase("remove")) {
				JUnitChild jUnitChild = serviceJSON.fromJson(JUnitChildUtil.getJSONValue(req));
				//just an example...
				if (RandomUtils.nextBoolean())
					service.delete(jUnitChild);
			} else {
				super.doGet(req, resp);
			}
		} catch (Exception e) {
			l.log(Level.SEVERE, "I failed to process a JSON request: " + req.getParameter("action"), e);
			throw new ServletException("I failed to process a JSON request: " + req.getParameter("action"), e);
		}
	}
*/
}
